<template>
  <div class="app-container">
   <el-collapse v-model="activeNames" @change="handleChange">
    <el-collapse-item title="基本信息" name="1">
      <div>作者姓名：<span>{{userData.nickname}}</span></div>
      <div>ID：<span>{{userData.username}}</span></div>
      <div>电话：<span>{{userData.phoneNum}}</span></div>
      <div>微信：<span>{{userData.wechatId}}</span></div>
      <div style="margin-bottom:20px;">邮箱：<span>{{userData.mailbox}}</span></div>
      <!-- <el-button type="primary">修改</el-button> -->
    </el-collapse-item>
  </el-collapse>
  <el-collapse v-model="activeNamessub" @change="handleChangesub">
    <el-collapse-item title="文章信息" name="1">
      <div>上传的文章共计：<span>{{articleData.uploadCount}}</span>篇</div>
      <div>发布：<span>{{articleData.publishCount}}</span>篇</div>
      <div>驳回：<span>{{articleData.rejectCount}}</span>篇</div>
      <div>修改：<span>{{articleData.modifyCount}}</span>篇</div>
      <div>基本面研报：<span>{{articleData.basiCount}}</span>篇</div>
      <div>跟踪研报：<span>{{articleData.tailCount}}</span>篇</div>
    </el-collapse-item>
  </el-collapse>
  </div>
</template>
<script>
  export default {
    name: 'dashboard',
    data() {
      return {
        activeNames: ['1'],
        activeNamessub: ['1'],
        userId: null,//用户id
        userData: {
          nickname: '',
          username: '',
          phoneNum: '',
          wechatId: '',
          mailbox: ''
        },
        articleData: {
          uploadCount: '',
          publishCount: '',
          rejectCount: '',
          modifyCount: '',
          basiCount: '',
          tailCount: ''
        }
      };
    },
    created () {
      this.userId = sessionStorage.getItem('userId')
      this.getUserInfo()
    },
    methods: {
      getUserInfo(){
        this.api({
          url: '/article/authorInfo',
          method: 'post',
          data: {
            userId: this.userId
          }
        }).then(data => {
          this.userData.nickname = data.nickname
          this.userData.username = data.username
          this.userData.phoneNum = data.phoneNum
          this.userData.wechatId = data.wechatId
          this.userData.mailbox = data.mailbox

          this.articleData.uploadCount = data.uploadCount
          this.articleData.publishCount = data.publishCount
          this.articleData.rejectCount = data.rejectCount
          this.articleData.modifyCount = data.modifyCount
          this.articleData.basiCount = data.basiCount
          this.articleData.tailCount = data.tailCount
        })
      },
      handleChange(val) {
        console.log(val);
      },
      handleChangesub(val) {
        console.log(val);
      }
    }

  }
</script>
